import { rmSync } from 'node:fs';
import { dirname, resolve } from 'node:path';

export default function () {
    return {
        name: 'clean-output-dir',
        generateBundle(options) {
            const filePath = options.file ? dirname(options.file) : options.dir;
            rmSync(resolve(filePath), { recursive: true, force: true });
        }
    };
}
